from sqlalchemy import Column, BigInteger, String, Integer, DateTime, Boolean
from app.models.base import BaseModel
from datetime import datetime

class User(BaseModel):
    __tablename__ = "user"
    
    id = Column(BigInteger, primary_key=True, index=True, autoincrement=True)
    unionid = Column(String(64), unique=True, index=True, nullable=True, comment="微信 UnionID（多个平台通用标识）")
    openid = Column(String(64), unique=True, index=True, nullable=True, comment="微信 OpenID（扫码登录唯一标识）")
    nickname = Column(String(64), nullable=True, comment="微信昵称")
    avatar = Column(String(255), nullable=True, comment="头像 URL")
    gender = Column(Integer, default=0, comment="性别：0=未知，1=男，2=女")
    login_type = Column(String(20), nullable=False, default="email", comment="登录方式（email / wechat / phone）")
    email = Column(String(100), unique=True, index=True, nullable=True, comment="邮箱（唯一，可用于登录）")
    password = Column(String(255), nullable=True, comment="加密后的密码（仅邮箱登录需要）")
    phone = Column(String(20), nullable=True, comment="手机号（预留）")
    status = Column(Integer, default=1, comment="状态：0=禁用，1=正常")
    last_login_at = Column(DateTime, nullable=True, comment="最后登录时间") 